/**
 * 
 */
package view.impl;

import java.io.FileNotFoundException;

import model.EMenuState;

import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.UnicodeFont;

/**
 * A class that implements the interface IViewState. Defines a state that displays
 * the a more or less empty screen shown between the main menu and in game state
 * and some indicator to show the player that the game is loading/connecting.
 * 
 * @author Julian Lindblad
 */
class ConnectingState implements IViewState {

	//private static ConnectingState INSTANCE = new ConnectingState();
	
	private UnicodeFont font = null;
	
	private int windowWidth = 800;
	private int windowHeight = 600;
	
	/**
	 * Private constructor, as defined in Singleton-pattern.
	 * @throws RenderException 
	 */
	ConnectingState() throws RenderException {
		try {
			font = FontContainer.getMenuFont();
		} catch (SlickException e) {
			throw new RenderException("Unable to load font in connecting screen.", e);
		} catch (FileNotFoundException e) {
			throw new RenderException("Unable to load font in connecting screen.", e);
		}
	}
	
	/* (non-Javadoc)
	 * @see client.view.IViewState#changeResolution(int, int)
	 */
	@Override
	public void changeResolution(int targetWidth, int targetHeight) {
		windowWidth = targetWidth;
		windowHeight = targetHeight;
	}

	/* (non-Javadoc)
	 * @see client.view.IViewState#render()
	 */
	@Override
	public void render(Graphics g) {
		int posX = (windowWidth - font.getWidth("Waiting for other player...")) / 2;
		int posY = (windowHeight - font.getHeight("Waiting for other player...")) / 2;
		font.drawString(posX, posY, "Waiting for other player...", new Color(255, 185, 25));
	}

	@Override
	public EMenuState getEMenuTyoe() {
		return EMenuState.CONNECTING;
	}
}
